﻿@model SearchModel
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Search").Text);

}
@using Nop.Web.Models.Catalog;
@using Nop.Web.Extensions;

<script type="text/javascript">
    $(document).ready(function () {

        $("#@Html.FieldIdFor(model => model.adv)").click(toggleAdvancedSearch);

        toggleAdvancedSearch();
    });

    function toggleAdvancedSearch() {

        if ($('#@Html.FieldIdFor(model => model.adv)').is(':checked')) {
            $('#advanced-search-block').show();
        }
        else {
            $('#advanced-search-block').hide();
        }
    }
</script>
<div class="panel panel-default form-panel">
    <div class="panel-heading">
        <h3>@T("Search")</h3>
    </div>
    <div class="panel-body">
        <div class="row">
            <div class="col-md-12">
                @using (Html.BeginRouteForm("ProductSearch", FormMethod.Get))
                {
                    <div class="basic-search form-group row">
                        @Html.LabelFor(model => model.q, new { @class = "col-md-2 control-label" }, ":")
                        <div class="col-md-6">
                            @Html.TextBoxFor(model => model.q, new { @class = "form-control" })
                        </div>
                    </div>
                    @Html.Widget("productsearch_page_basic")
                    <div class="form-group row reversed">
                        @Html.CheckBoxFor(model => model.adv)
                        @Html.LabelFor(model => model.adv, new { @class = "col-md-2 control-label" })
                    </div>
                <hr />
                <div class="advanced-search" id="advanced-search-block">
                    @if (Model.AvailableCategories.Count > 0)
                        {
                        <div class="form-group row">
                            @Html.LabelFor(model => model.cid, new { @class = "col-md-2 control-label" }, ":")
                            <div class="col-md-6">
                                @Html.DropDownListFor(model => model.cid, Model.AvailableCategories, new { @class = "form-control" })
                            </div>
                        </div>
                        <div class="form-group row reversed">
                            <div class="col-md-8">
                                @Html.CheckBoxFor(model => model.isc)
                                @Html.LabelFor(model => model.isc)
                            </div>
                        </div>
                        }
                    @if (Model.AvailableManufacturers.Count > 0)
                        {
                        <div class="form-group row">
                            @Html.LabelFor(model => model.mid, new { @class = "col-md-2 control-label" }, ":")
                            <div class="col-md-6">
                                @Html.DropDownListFor(model => model.mid, Model.AvailableManufacturers, new { @class = "form-control" })
                            </div>
                        </div>
                        }
                    <div class="form-group row">
                        <div class="col-md-2">
                            <label>@T("Search.PriceRange"):</label>
                        </div>
                        <div class="col-md-8">
                            <div class="price-range row">
                                <div class="col-md-1">@T("Search.PriceRange.From")</div>
                                <div class="col-md-3">@Html.TextBoxFor(model => model.pf, new { @class = "form-control" })</div>
                                <div class="col-md-1">@T("Search.PriceRange.To")</div>
                                <div class="col-md-3">@Html.TextBoxFor(model => model.pt, new { @class = "form-control" })</div>
                            </div>
                        </div>
                    </div>
                    <div class="inputs reversed">
                        @Html.CheckBoxFor(model => model.sid)
                        @Html.LabelFor(model => model.sid)
                    </div>
                    @Html.Widget("productsearch_page_advanced")
                </div>
                <div class="forum-group row buttons">
                    <div class="col-md-12">
                    <input type="submit" class="btn btn-default" value="@T("Search")" />
                        </div>
                </div>
                }
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                @Html.Widget("productsearch_page_before_results")
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                @if (!String.IsNullOrEmpty(Model.Warning))
                {
                    <div class="clearfix space10"></div>
                    <strong class="alert alert-info">
                        @Model.Warning
                    </strong>
                }
                @if (Model.NoResults)
                {
                    <div class="row">
                        <div class="col-md-12">
                            <div class="alert alert-danger">
                                @T("Search.NoResultsText")
                            </div>
                        </div>
                    </div>
                }
                @if (Model.Products.Count > 0)
                {
                    <div class="row">
                        <div class="col-md-12">
                            <div class="product-list">
                                @foreach (var product in Model.Products)
                                {
                                    <div class="item-box">
                                        <legend class="top_padding15"></legend>
                                        @Html.Partial("_ProductBox", product)
                                    </div>
                                }
                            </div>
                        </div>
                    </div>

                }
                <div class="row">
                    <div class="col-md-12">
                        <div class="pager">
                            @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber").BooleanParameterName("adv").BooleanParameterName("isc").BooleanParameterName("sid")
                        </div>
                    </div>
                </div>

            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                @Html.Widget("productsearch_page_after_results")
            </div>
        </div>
    </div>
</div>
